﻿Imports DTO
Public Class Sanh_DAL
    Dim connect As Connection
    Dim stringCommand As String
    Dim sanh As Sanh
    Dim ds_Sanh As List(Of Sanh)

    Public Function LoadData() As List(Of Sanh)
        connect = New Connection()
        stringCommand = "Select * From Sanh"
        ds_Sanh = New List(Of Sanh)
        Dim dt As New DataTable()
        dt = connect.LoadData(stringCommand)
        For i As Integer = 0 To dt.Rows.Count - 1
            Dim id As Integer = dt.Rows(i)(0)
            Dim tenSanh As String = dt.Rows(i)(1).ToString()
            Dim loaiSanh As String = dt.Rows(i)(2).ToString()
            Dim soBan As Integer = dt.Rows(i)(3)
            Dim donGiaBan As Double = dt.Rows(i)(4)

            sanh = New Sanh(id, tenSanh, loaiSanh, soBan, donGiaBan)
            ds_Sanh.Add(sanh)
        Next
        Return ds_Sanh
    End Function

    Public Function Insert(ByVal sanh As Sanh)
        connect = New Connection()
        stringCommand = "Insert Sanh(ID,TenSanh,LoaiSanh,SoBan,DonGiaBan) Values('" & sanh.ID & "','" & sanh.Tên_Sảnh & "','" & sanh.Loại_Sảnh & "','" & sanh.Số_Bàn & "','" & sanh.Đơn_Giá_Bàn & ")"
        Return connect.ExecuteData(stringCommand)
    End Function

    'Public Function LoadData(ByVal id As Integer) As Sanh
    '    connect = New Connection()
    '    stringCommand = "Select * From Sanh Where ID = " & id
    '    Dim dt As New DataTable()
    '    dt = connect.LoadData(stringCommand)
    '    Dim tenSanh As String = dt.Rows(0)(1).ToString()
    '    Dim loaiSanh As String = dt.Rows(0)(2).ToString()
    '    Dim soBan As Integer = dt.Rows(0)(3)
    '    Dim donGiaBan As Double = dt.Rows(0)(4)

    '    sanh = New Sanh(id, tenSanh, loaiSanh, soBan, donGiaBan)

    '    Return sanh
    'End Function
End Class
